/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package common.model.message;

import common.model.Visitor;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/**
 *
 * @author nicolas
 */
public class DetailsForMessage extends AbstractVisitorBasedMessage{

    private String nameDest;
    /**
     * Message format : DETAILSFOR src dest x z rot guide
     * @param line
     */
    public DetailsForMessage(String line) {
        super();
        StringTokenizer st = new StringTokenizer(line, " ");
        List<Object> listElems = new ArrayList();
        while(st.hasMoreElements()){
            listElems.add(st.nextElement());
        }
        this.getVisitor().setUserName((String)listElems.get(1));
        this.nameDest = (String)listElems.get(2);
        this.getVisitor().setX(Double.parseDouble((String)listElems.get(3)));
        this.getVisitor().setZ(Double.parseDouble((String)listElems.get(4)));
        this.getVisitor().setRotation(Double.parseDouble((String)listElems.get(5)));
        this.getVisitor().setGuide(Boolean.parseBoolean((String)listElems.get(6)));
    }

    public DetailsForMessage(Visitor visitor, String nameDest) {
        super(visitor);
        this.nameDest = nameDest;
    }


    public String messageToString() {
        return "DETAILSFOR " + this.getVisitor().getUserName() + " " +
                this.nameDest + " "
                + this.getVisitor().getX() + " "
                + this.getVisitor().getZ() + " "
                + this.getVisitor().getRotation() + " "
                + this.getVisitor().isGuide();
    }

    public String getNameDest() {
        return nameDest;
    }

    public String getNameSrc() {
        return this.getVisitor().getUserName();
    }
}
